---
title: "Headers Collection"
description: "The \"Headers Collection\" rule can be used to add span attributes by collecting HTTP Headers data."
sidebarTitle: "Headers Collection"
icon: "webhook"
---

<Info>
  This Instrumentation Rule is currently only available with the Odigos **Enterprise** plan.<br />
  [Contact us](https://odigos.io/) for more information.
</Info>

## Considerations

<Warning>
  Before enabling **headers collection**, please note the following:
  - The support for headers collection varies between instrumentation libraries and languages.
  - HTTP headers might contain PII data (like cookies or API keys), thus it is recommended to review each requested header before configuring it to avoid sensitive information.
</Warning>

## Configuration Options

<AccordionGroup>
  <Accordion title="headerKeys">
    **headerKeys** `string[]` : Limit payload collection to specific header keys.
    - This field is *optional*
    - If not specified, no headers will be collected.
    - If set to `["*"]`, all supported headers will be collected.
  </Accordion>
</AccordionGroup>

<Note>
  Any unspecified headers will not be recorded.
</Note>

## Basic Example

The following example demonstrates how to enable headers collection for all supported workloads and instrumentation libraries in the cluster.

<Steps>
  <Step>
    Create a YAML file with the following content:

    ```yaml headers-collection.yaml
    apiVersion: odigos.io/v1alpha1
    kind: InstrumentationRule
    metadata:
      name: collect-all-headers
      namespace: odigos-system
    spec:
      ruleName: "collect all supported headers"
      headersCollection:
        headerKeys: ["*"]
    ```
  </Step>
  <Step>
    Apply the action to the cluster:

    ```shell
    kubectl apply -f headers-collection.yaml
    ```
  </Step>
</Steps>
